home *** CD-ROM | disk | FTP | other *** search
- if(!init)
- {
- orig_scale = _xscale;
- hitarea._visible = 0;
- walking = false;
- parrying = false;
- attacking = false;
- jumping = false;
- fall_distance = 0;
- init = true;
- side = "L";
- lastdecision = 0;
- deadcount = 0;
- floor = 62;
- walkdistance = 25;
- reach = 45;
- hit2_reach = 63;
- damage = 20;
- total_ki = 30;
- ki = total_ki;
- ki_cost = 10;
- pushfactor = 2;
- total_hp = 120;
- hp = total_hp;
- regen_rate = 0.3;
- score = 1500;
- _root.createPic("pic_bush",this);
- }
- attacking = false;
- speed = 0;
- walking = false;
- this.onEnterFrame = function()
- {
- if(!init)
- {
- return undefined;
- }
- if(dead)
- {
- deadcount++;
- if(deadcount > 1000)
- {
- this.removeMovieClip();
- unloadMovie(this);
- }
- gotoAndStop("die");
- this._x -= _hitomi.speed;
- return undefined;
- }
- lastdecision++;
- onDie();
- onWalk();
- doCalcs();
- var _loc3_ = fallback();
- if(_loc3_ == undefined)
- {
- _loc3_ = 0;
- }
- var _loc4_ = _root.hitomi.speed;
- checkHits();
- decide();
- this._x -= _loc4_;
- this._x += _loc3_;
- if(!walking && !attacking && !turning && !recieving)
- {
- unwalk();
- gotoAndStop("stand");
- }
- };
- checkHits = function()
- {
- if(this.hitarea.hitTest(_hitomi.hitarea))
- {
- onHit();
- }
- if(_root.hitomi.hitTest(_X + club._x * getDirection(),_Y + club._y,true))
- {
- _root.hitomi.recieveHit(this);
- }
- if(_root.hitomi.hitTest(_X + (club._x + 3) * getDirection(),_Y + club._y,true))
- {
- _root.hitomi.recieveHit(this);
- }
- if(_root.hitomi.hitTest(_X + (club._x - 3) * getDirection(),_Y + club._y,true))
- {
- _root.hitomi.recieveHit(this);
- }
- };
- doCalcs = function()
- {
- if(!(walking || slashing || jumping || parrying || turning || recieving))
- {
- ki += regen_rate;
- }
- if(ki > total_ki)
- {
- ki = total_ki;
- }
- if(hp > total_hp)
- {
- hp = total_hp;
- }
- if(ki < 0)
- {
- ki = 0;
- }
- if(hp < 1)
- {
- hp = 0;
- die();
- }
- pic.bars.hp._xscale = Math.ceil(hp / total_hp * 100);
- pic.bars.ki._xscale = Math.ceil(ki / total_ki * 100);
- };
- getDirection = function()
- {
- if(orig_scale == _xscale)
- {
- return 1;
- }
- return -1;
- };
- bombHit = function(hit_by, dmg, pushf)
- {
- hp -= dmg;
- };
- onHit = function()
- {
- _root.hitcount = _root.hitcount + 1;
- if(_root.hitcount > 1000)
- {
- _root.hitcount = 0;
- }
- hp -= _hitomi.damage;
- _root._score += _hitomi.damage;
- var _loc3_ = _root.attachMovie("mc_blood01","blood" + hitcount,6000 + hitcount);
- _loc3_._rotation = random(360);
- var _loc4_ = random(150) + 100;
- _loc3_._xscale = _loc4_;
- _loc3_._yscale = _loc4_;
- if(_hitomi.side == "R")
- {
- _loc3_._x = _hitomi._x + _hitomi.hitarea._x;
- _loc3_._y = _hitomi._y + _hitomi.hitarea._y;
- }
- else
- {
- _loc3_._x = _hitomi._x - _hitomi.hitarea._x;
- _loc3_._y = _hitomi._y + _hitomi.hitarea._y;
- }
- fall_distance = _hitomi.pushback * 2;
- fallback = function()
- {
- fall_distance--;
- if(fall_distance < 1)
- {
- delete this.fallback;
- fall_distance = 0;
- return 0;
- }
- return _hitomi.getDirection() * (fall_distance / 2);
- };
- soundsList = ["loud_metal_hit","blow01","beat","cabasa","zddd1kick1","zddd1kick2","zddd1tamb"];
- playSound(soundsList);
- };
- die = function()
- {
- _root.removePic(pic);
- dead = true;
- walking = false;
- slashing = false;
- attacking = false;
- speed = 0;
- gotoAndStop("die");
- play();
- };
- decide = function()
- {
- if(dead)
- {
- return undefined;
- }
- if(!walking && !attacking || lastdecision > 250)
- {
- lastdecision = 0;
- var _loc2_ = random(20);
- attacking = false;
- if(_loc2_ == 0)
- {
- walk_distance = random(walkdistance) + 6;
- walk();
- return undefined;
- }
- var _loc1_ = Math.abs(_hitomi._x - _X);
- if(_loc2_ < 3)
- {
- if(_loc1_ < 10 || _loc1_ > reach)
- {
- if(_hitomi._x < _X)
- {
- left();
- }
- else
- {
- right();
- }
- return undefined;
- }
- }
- if(_loc1_ < reach)
- {
- if(_hitomi._x > _X && side == "L")
- {
- turn("R");
- }
- if(_hitomi._x < _X && side == "R")
- {
- turn("L");
- }
- attack();
- return undefined;
- }
- if(_loc1_ < hit2_reach)
- {
- if(_hitomi._x > _X && side == "L")
- {
- turn("R");
- }
- if(_hitomi._x < _X && side == "R")
- {
- turn("L");
- }
- attack2();
- return undefined;
- }
- unwalk();
- gotoAndStop("stand");
- }
- };
- attack = function()
- {
- if(!attacking)
- {
- if(ki < ki_cost)
- {
- walking = false;
- attacking = false;
- walk_distance = random(walkdistance) + 6;
- walk();
- return undefined;
- }
- walking = false;
- speed = 0;
- attacking = true;
- ki -= ki_cost;
- gotoAndStop("hit");
- play();
- }
- };
- attack2 = function()
- {
- if(!attacking)
- {
- if(ki < ki_cost)
- {
- walking = false;
- attacking = false;
- walk_distance = random(walkdistance) + 6;
- walk();
- return undefined;
- }
- walking = false;
- speed = 0;
- attacking = true;
- ki -= ki_cost;
- gotoAndStop("hit2");
- play();
- }
- };
- if(!init)
- {
- side = "L";
- orig_scale = _xscale;
- init = true;
- }
- right = function()
- {
- turn("R");
- };
- left = function()
- {
- turn("L");
- };
- turn = function(sideto)
- {
- if(!sideto)
- {
- if(side == "L")
- {
- sideto = "R";
- }
- else
- {
- sideto = "L";
- }
- }
- if(side != sideto)
- {
- if(!jumping)
- {
- turnTo = sideto;
- walking = false;
- jumping = false;
- parrying = false;
- attacking = false;
- if(sideto == "L")
- {
- _xscale = orig_scale;
- }
- else
- {
- _xscale = - orig_scale;
- }
- side = sideto;
- }
- }
- else
- {
- turning = false;
- walk_distance = random(walkdistance) + 6;
- walk();
- }
- };
- walk = function()
- {
- if(walking || attacking || jumping || parrying || turning || dead)
- {
- return undefined;
- }
- walking = true;
- gotoAndStop("walk");
- play();
- this.count = 0;
- this.onWalk = function()
- {
- count++;
- walking = true;
- if(side == "R")
- {
- _X = _X + 1.5;
- }
- else
- {
- _X = _X - 1.5;
- }
- if(count > Math.abs(walk_distance))
- {
- delete this.onWalk;
- walking = false;
- unwalk();
- }
- };
- };
- unwalk = function()
- {
- if(walking && !dead)
- {
- walking = false;
- speed = 0;
- gotoAndStop("stand");
- }
- };
- playSound = function(ids)
- {
- _root.sounds.playSound(ids);
- };
- stop();
-